home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / arrays / vsflex / module.bas < prev    next >
Encoding:
BASIC Source File  |  1995-05-23  |  2.6 KB  |  115 lines

  1. Option Explicit
  2.  
  3. Global Const NUMREC = 11            ' Number of Records in my array
  4.  
  5. Type MYTYPE
  6.     Country As String
  7.     Product As String
  8.     Type As String
  9.     Sales As String
  10. End Type
  11.  
  12. Global MyData(NUMREC) As MYTYPE
  13.  
  14. Sub DoFillArray (c As Control, FromRow%, FromCol%)
  15.  
  16.     '------------------------------------------------------------
  17.     ' c is the vsFlexArray control where the data will be added
  18.  
  19.     Dim i%
  20.     For i = 0 To NUMREC - 1
  21.         ' for each row
  22.         c.Row = FromRow + i
  23.  
  24.         ' fill out the column data from MyData
  25.         c.Col = FromCol: c = MyData(i).Country
  26.         c.Col = c.Col + 1: c = MyData(i).Product
  27.         c.Col = c.Col + 1: c = MyData(i).Type
  28.         c.Col = c.Col + 1: c = MyData(i).Sales
  29.     Next i
  30.  
  31. End Sub
  32.  
  33. Sub DoGetData ()
  34.  
  35.     MyData(0).Country = "Country"
  36.     MyData(0).Product = "Product"
  37.     MyData(0).Type = "Type"
  38.     MyData(0).Sales = "Sales"
  39.  
  40.     MyData(1).Country = "USA"
  41.     MyData(1).Product = "Gold"
  42.     MyData(1).Type = "Import"
  43.     MyData(1).Sales = "450"
  44.  
  45.     MyData(2).Country = "USA"
  46.     MyData(2).Product = "Gold"
  47.     MyData(2).Type = "Export"
  48.     MyData(2).Sales = "15"
  49.  
  50.     MyData(3).Country = "USA"
  51.     MyData(3).Product = "Silver"
  52.     MyData(3).Type = "Import"
  53.     MyData(3).Sales = "215"
  54.  
  55.     MyData(4).Country = "USA"
  56.     MyData(4).Product = "Silver"
  57.     MyData(4).Type = "Export"
  58.     MyData(4).Sales = "12"
  59.  
  60.     MyData(5).Country = "Canada"
  61.     MyData(5).Product = "Silver"
  62.     MyData(5).Type = "Import"
  63.     MyData(5).Sales = "321"
  64.  
  65.     MyData(6).Country = "Canada"
  66.     MyData(6).Product = "Silver"
  67.     MyData(6).Type = "Export"
  68.     MyData(6).Sales = "812"
  69.  
  70.     MyData(7).Country = "Canada"
  71.     MyData(7).Product = "Gold"
  72.     MyData(7).Type = "Import"
  73.     MyData(7).Sales = "321"
  74.  
  75.     MyData(8).Country = "Canada"
  76.     MyData(8).Product = "Gold"
  77.     MyData(8).Type = "Export"
  78.     MyData(8).Sales = "812"
  79.  
  80.     MyData(9).Country = "Germany"
  81.     MyData(9).Product = "Gold"
  82.     MyData(9).Type = "Import"
  83.     MyData(9).Sales = "81"
  84.  
  85.     MyData(10).Country = "Germany"
  86.     MyData(10).Product = "Gold"
  87.     MyData(10).Type = "Export"
  88.     MyData(10).Sales = "-92"
  89.  
  90. End Sub
  91.  
  92. Sub DoGridTitles (c As Control)
  93.  
  94.     Dim i%
  95.     '-------------------------------------------------
  96.     ' initialize grid
  97.  
  98.     c.ColWidth(0) = c.ColWidth(0) / 2
  99.     c.Col = 0
  100.     For i = 1 To c.Rows - 1
  101.         c.Row = i
  102.         c = i
  103.     Next
  104.     c.Row = 0
  105.     For i = 1 To c.Cols - 1
  106.         c.Col = i
  107.         c = Chr$(64 + i)
  108.     Next
  109.     c.Col = 1
  110.     c.Row = 1
  111.     c.Refresh
  112.  
  113. End Sub
  114.  
  115.